﻿using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIA.Integration.Domain;

namespace VIA.SiMoJi.Domain
{
    [AddINotifyPropertyChangedInterface]
    public class LijuModel
    {
        public int Number { get; set; }
        /// <summary>
        /// 当前值(电流)A
        /// </summary>
        public double Current { get; set; }
        /// <summary>
        /// 差值（力矩 单位克）
        /// </summary>
        public double Offset { get; set; }
        /// <summary>
        /// 额定电流
        /// </summary>
        public double Base { get; set; }
        public Quality Quality { get; set; }
        public void Calc(bool isUse, double upperLimit)
        {
            var offset = Current / 1000 * 7.5 * 102;
            Offset = Math.Round(offset * 1000, 1);
            if (isUse)
            {
                Quality = Offset < upperLimit ? Quality.Ok : Quality.Ng;
            }
            else
            {
                Quality = Quality.Ok;
            }
        }
        public void Calc2(bool isUse, double upperLimit)
        {
            //开环推力(Kg)=(电流/1000*额定电流*(电流与N比例))/9.8   开环推力，单位是N------N=m*g-----m=N/9.8*1000才是g
            var offset = (Current / 1000 * Base * 7.5) / 9.8;
            Offset = Math.Round(offset * 1000, 1);
            if (isUse)
            {
                Quality = Offset < upperLimit ? Quality.Ok : Quality.Ng;
            }
            else
            {
                Quality = Quality.Ok;
            }
        }
    }
}
